#!/usr/bin/perl
use strict;

package csinfo;

sub csinfo {
    my ($csnum,$remote,$dbh,$input)=@_;
    my $sth;
    $sth=$dbh->prepare("SELECT channel,owner,registered,url FROM channels WHERE channel = '$$input[4]';");
    $sth->execute;
    my @chaninfo = $sth->fetchrow_array;

    if ($$input[4] eq "") {
	print $remote "$csnum O $$input[0] :Syntax :INFO <#channel>\n";
    }
    elsif ($chaninfo[0] eq "") {
	print $remote "$csnum O $$input[0] :$$input[4] is not a registered channel.\n";
    }
    else {
	print $remote "$csnum O $$input[0] :Channel INFO For : \cB$chaninfo[0]\cB\n";
	print $remote "$csnum O $$input[0] :Owner            : $chaninfo[1]\n";
	$chaninfo[2] = localtime($chaninfo[2]);
	print $remote "$csnum O $$input[0] :Registered at    : $chaninfo[2]\n";
	if ($chaninfo[3] eq "") {
	    print $remote "$csnum O $$input[0] :URL              : <none>\n";
	}
	else {
	    print $remote "$csnum O $$input[0] :URL              : $chaninfo[3]\n";
	}
    }
    undef @chaninfo;
}
1;
